package com.koron.common.core.util.mail;

import com.koron.common.core.business.configsettings.utils.ConfigInfoTool;
import lombok.Data;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author jzp
 * @since 2021/11/4
 */
@Data
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class MailConfigProperties {
    private String mailHost;
    private Integer mailPort;
    private String mailUsername;
    private String mailPassword;
    private String mailFrom;
    private String timeout;
    private String personal;

    public MailConfigProperties() {
        Map<String, String> map = ConfigInfoTool.getConfigByCode("common", "mail");
        if (map.isEmpty()) {
            return;
        }
        this.mailHost = map.get("mailHost");
        this.mailPort = Integer.valueOf(map.get("mailPort"));
        this.mailUsername = map.get("mailUsername");
        this.mailPassword = map.get("mailPassword");
        this.mailFrom = map.get("mailFrom");
        this.timeout = map.get("timeout");
        this.personal = map.get("personal");
    }
}
